﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Aga.Psad.Mvc.Models;
using Aga.Psad.Mvc.Helpers;
using Aga.Psad.Backend.Repositories;
using Aga.Psad.Mvc.Models.Visualizador;
using PagedList;

namespace Aga.Psad.Mvc.Controllers
{
    public abstract class ControllerBase : Controller
    {
        public ControllerBase()
        {
            ViewData["Menu"] = "home"; // by default
        }
        
        protected ActionResult ShowError(Exception ex)
        {
            string controllerName = this.GetType().Name.Replace("Controller", string.Empty);

            return View("Error", new ErrorViewModel(controllerName) { Message = ex.Message, Details = ex.StackTrace });
        }

        protected ActionResult ShowDetailedError(ErrorViewModel model)
        {
            string controllerName = this.GetType().Name.Replace("Controller", string.Empty);

            return View("Error", model);
        }

        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);
        }

        protected override void OnException(ExceptionContext filterContext)
        {
            base.OnException(filterContext);
        }

    }
}
